From 4786dcd4fdb67b7997e520197ad3d6645be16f7f Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 2 Sep 2008 05:05:49 +0000 Subject: [PATCH] Add garminextension,humminbirdextensions options to GPX writer so we can write depth. --- gpx.c | 48 ++++++++++++++++++++++++++++++++---------------- humminbird.c | 1 - 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/gpx.c b/gpx.c index e09319895..6363d9e11 100644 --- a/gpx.c +++ b/gpx.c @@ -32,6 +32,7 @@ static xml_tag *cur_tag; static vmem_t cdatastr; static char *opt_logpoint = NULL; static char *opt_humminbirdext = NULL; +static char *opt_garminext = NULL; static int logpoint_ct = 0; static const char *gpx_version; @@ -1575,6 +1576,7 @@ gpx_write_common_acc(const waypoint *waypointp, const char *indent) } } + static void gpx_write_common_position(const waypoint *waypointp, const char *indent) { @@ -1582,26 +1584,29 @@ gpx_write_common_position(const waypoint *waypointp, const char *indent) gbfprintf(ofd, "%s%f\n", indent, waypointp->altitude); } - if (waypointp->depth != 0) { - if (opt_humminbirdext) { - gbfprintf(ofd, "%s\n", indent); - gbfprintf(ofd, "%s %f\n", - indent, waypointp->depth*100.0); - gbfprintf(ofd, "%s\n", indent); - } -/* - gbfprintf(ofd, "%s\n", indent); - gbfprintf(ofd, "%s %f\n", - indent, waypointp->depth); - gbfprintf(ofd, "%s\n", indent); -*/ - } if (waypointp->creation_time) { gbfprintf(ofd, indent); xml_write_time(ofd, waypointp->creation_time, waypointp->microseconds, "time"); } } +static void +gpx_write_common_depth(const waypoint *waypointp, const char *indent) +{ + if (waypointp->depth != 0) { + if (opt_humminbirdext || opt_garminext) { + gbfprintf(ofd, "%s\n", indent); + if (opt_humminbirdext) + gbfprintf(ofd, "%s %f\n", + indent, waypointp->depth*100.0); + if (opt_garminext) + gbfprintf(ofd, "%s %f\n", + indent, waypointp->depth); + gbfprintf(ofd, "%s\n", indent); + } + } +} + static void gpx_write_common_description(const waypoint *waypointp, const char *indent, const char *oname) @@ -1656,6 +1661,7 @@ gpx_waypt_pr(const waypoint *waypointp) /* MapSource doesn't accepts extensions from 1.0 */ garmin_fs_xml_fprint(ofd, waypointp); } + gpx_write_common_depth(waypointp, " "); gbfprintf(ofd, "\n"); } @@ -1714,6 +1720,7 @@ gpx_track_disp(const waypoint *waypointp) fprint_xml_chain( fs_gpx->tag, waypointp ); } + gpx_write_common_depth(waypointp, " "); gbfprintf(ofd, "\n"); } @@ -1766,6 +1773,7 @@ gpx_route_disp(const waypoint *waypointp) fprint_xml_chain( fs_gpx->tag, waypointp ); } + gpx_write_common_depth(waypointp, " "); gbfprintf(ofd, " \n"); } @@ -1811,7 +1819,8 @@ gpx_write(void) time_t now = 0; int short_length; - if (opt_humminbirdext) gpx_wversion = "1.1"; + if (opt_humminbirdext || opt_garminext) + gpx_wversion = (char *)"1.1"; gpx_wversion_num = strtod(gpx_wversion, NULL) * 10; @@ -1833,8 +1842,12 @@ gpx_write(void) gbfprintf(ofd, "\n", xsi_schema_loc); @@ -1918,7 +1931,10 @@ arglist_t gpx_args[] = { { "gpxver", &gpx_wversion, "Target GPX version for output", "1.0", ARGTYPE_STRING, ARG_NOMINMAX}, { "humminbirdextensions", &opt_humminbirdext, - "Add info (depth) as humminbird extension", + "Add info (depth) as Humminbird extension", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + { "garminextensions", &opt_garminext, + "Add info (depth) as Garmin extension", NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, ARG_TERMINATOR }; diff --git a/humminbird.c b/humminbird.c index 012f372c6..63202bcec 100644 --- a/humminbird.c +++ b/humminbird.c @@ -332,7 +332,6 @@ humminbird_read_track(gbfile* fin) { gbint32 accum_north; double g_lat; - if (! gbfread(&th, 1, sizeof(th), fin)) fatal(MYNAME ": Unexpected end of file reading header!\n"); -- 2.30.2